import request from '../../../util/request';
import {userServer} from '../../../config/config';

/**
 * 注册用户
 */
function register({avatarId, username, email, mobilePhone, password, nickname, realName, idCard, sex, birthTime}) {
	return request(userServer('/api/register/register'), {
		data: {avatarId, username, email, mobilePhone, password, nickname, realName, idCard, sex, birthTime}
	});
}

function resetPassword({identity, random, password}) {
	return request(userServer('/api/register/resetPassword'), {
		data: {identity, random, password}
	});
}

/**
 * 更新用户
 */
function updateUser({userId, avatarId, username, email, mobilePhone, password, nickname, realName, idCard, sex, birthTime}) {
	return request(userServer('/api/register/updateUser'), {
		data: {userId, avatarId, username, email, mobilePhone, password, nickname, realName, idCard, sex, birthTime}
	});
}

/**
 * 检验用户名存在
 */
function existUsername({username}) {
	return request(userServer('/api/register/existUsername'), {
		data: {username}
	});
}

/**
 * 检验邮箱存在
 */
function existEmail({email}) {
	return request(userServer('/api/register/existEmail'), {
		data: {email}
	});
}

/**
 * 检验手机号存在
 */
function existMobilePhone({mobilePhone}) {
	return request(userServer('/api/register/existMobilePhone'), {
		data: {mobilePhone}
	});
}

export {
	register,
	resetPassword,
	updateUser,
	existUsername,
	existEmail,
	existMobilePhone,
}
